package com.phone.client.controller;

import com.seventh.common.pojo.R;
import com.phone.client.poji.entry.TbMemberLevel;
import com.phone.client.poji.vo.LevelVo;
import com.phone.client.service.LevelService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: clms-seventh
 * @description: 会员等级控制层
 * @author: 杨佳琪
 * @create: 2021-07-24 09:15
 **/
@RestController
@RequestMapping("client/lev")
@Api(tags="会员等级控制层")
public class LevelController {
    @Resource
    private LevelService levelService;

    @ApiOperation("分页查询")
    @PostMapping("initLevelTable/{currentPage}/{pageSize}")
    public R initClientTable(@ApiParam(value = "页码",name = "currentPage") @PathVariable("currentPage") Integer currentPage,@ApiParam(value = "条数",name = "pageSize")@PathVariable("pageSize") Integer pageSize,
                             @RequestBody LevelVo levelVo){
        return levelService.findAllLeveltByPage(currentPage,pageSize,levelVo);
    }

    @ApiOperation("删除")
    @DeleteMapping("deleteLevel/{id}")
    public R deleteLevel(@PathVariable Integer id){
        return levelService.deleteLevel(id);
    }

    @ApiOperation("修改")
    @PutMapping("updateLevel")
    public R updateLevel(@RequestBody TbMemberLevel tbMemberLevel){
        return levelService.updateLevel(tbMemberLevel);
    }

    @ApiOperation("新增")
    @PostMapping("insertLevel")
    public R insertLevel(@RequestBody TbMemberLevel tbMemberLevel){
        System.out.println(tbMemberLevel);
        return levelService.insertLevel(tbMemberLevel);
    }

    @ApiOperation("修改的回显")
    @GetMapping("findElvelById/{id}")
    public R findElvelById(@PathVariable Integer id){
        return levelService.findElvelById(id);
    }

    @PostMapping("selName")
    @ApiOperation("查询等级名称是否唯一")
    public R selName(@ApiParam("等级信息")@RequestBody TbMemberLevel tbMemberLevel){
        return levelService.selName(tbMemberLevel);
    }

    @PostMapping("findMumber")
    @ApiOperation("下拉")
    public R findMumber(){
        return levelService.findMumber();
    }
}

